package tsing.kc_work.cology.intention;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Optional;

/**
 * @Date 2024/7/29 14:24
 * @Author Tsing
 */
public class TestDemo {
    @Autowired
    private SupplierIntentionMapper mapper;
    public static void main(String[] args) {
        String param = "{\"intentionObject\":{\"intentionId\":\"id\",\"intentionalSection\":\"1\",\"email\":\"230832599@qq.com\",\"contactPhoneNumber\":\"15173343158\",\"contactName\":\"吴清平\",\"enterpriseName\":\"科创\",\"businessLicense\":\"/1.pdf\",\"unifiedSocialCreditCode\":\"PT9527\",\"customerDemand\":\"这个权益太拉了\",\"operateTime\":\"2024-07-29 14:27:56\"}}";
        IntentionParam intentionParam = JSON.parseObject(param, IntentionParam.class);
        insertOrUpdateIntentionMethod(intentionParam);
    }
    private static void insertOrUpdateIntentionMethod(IntentionParam intentionParam){
        System.out.println(JSON.toJSONString(intentionParam));
        System.out.println(intentionParam.getIntentionObject().getIntentionId());
        if(!Optional.ofNullable(intentionParam.getIntentionObject()).isPresent()){
            System.out.println("参数缺失");
        }
        SupplierIntentionDomain bean = intentionParam.getIntentionObject();
        bean.setInsertTime(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        bean.setUpdateTime(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));

        /*
            根据企业名称 判断意向表是否存在？
                  存在：接口返回失败，结果返回：该企业意向信息已存在
                不存在：
                       1.入库（意向表）
                       2.根据企业名称查询商户表，获得商户入驻状态
                       3.调接口返回接洽信息

         */



        // 插入


        // 插入或更新
//        mapper.saveOrUpdateUser(bean);
    }
}
